package models

import (
	"github.com/astaxie/beego/logs"
	"github.com/astaxie/beego/orm"
)

func (s *SecurityReviewer) Read(filed ...string) (ok bool) {
	o := orm.NewOrm()
	err := o.Read(s, filed...)
	if err != nil {
		logs.Error(err)
		return false
	}
	return true
}

func (s *OpenGaussSecurityReviewer) Read(filed ...string) (ok bool) {
	o := orm.NewOrm()
	err := o.Read(s, filed...)
	if err != nil {
		logs.Error(err)
		return false
	}
	return true
}

func GetSecurityReviewerList() (list []SecurityReviewer, err error) {
	o := orm.NewOrm()
	_, err = o.QueryTable("cve_security_reviewer").All(&list)
	return list, err
}

func GetGuassSecurityReviewerList() (list []OpenGaussSecurityReviewer, err error) {
	o := orm.NewOrm()
	_, err = o.QueryTable("cve_open_gauss_security_reviewer").All(&list)
	return list, err
}

func GetSporeSecurityReviewerList() (list []MindSporeSecurityReviewer, err error) {
	o := orm.NewOrm()
	_, err = o.QueryTable("cve_mind_spore_security_reviewer").All(&list)
	return list, err
}

func GetOpenLookengSecurityReviewerList() (list []OpenLookengSecurityReviewer, err error) {
	o := orm.NewOrm()
	_, err = o.QueryTable("cve_open_lookeng_security_reviewer").All(&list)
	return list, err
}

func (s *MindSporeSecurityReviewer) Read(filed ...string) (ok bool) {
	o := orm.NewOrm()
	err := o.Read(s, filed...)
	if err != nil {
		logs.Error(err)
		return false
	}
	return true
}

func (s *OpenLookengSecurityReviewer) Read(filed ...string) (ok bool) {
	o := orm.NewOrm()
	err := o.Read(s, filed...)
	if err != nil {
		logs.Error(err)
		return false
	}
	return true
}